Skip to content

enhance new codes to XPU, and make them be device agnostic#3890

Merged
SunMarc merged 4 commits intohuggingface:mainfrom
yao-matrix:device-agnostic
Jan 27, 2026
Merged

enhance new codes to XPU, and make them be device agnostic#3890
SunMarc merged 4 commits intohuggingface:mainfrom
yao-matrix:device-agnostic

Conversation

@yao-matrix
Copy link
Contributor

No description provided.

Signed-off-by: Matrix YAO <matrix.yao@intel.com>
Signed-off-by: Matrix YAO <matrix.yao@intel.com>
@yao-matrix yao-matrix changed the title extend more cases to xpu and make some code/doc device agnostic enhance some new code to XPU, and make some code/docs be device agnostic Dec 22, 2025
@yao-matrix yao-matrix changed the title enhance some new code to XPU, and make some code/docs be device agnostic enhance new codes to XPU, and make them be device agnostic Dec 22, 2025
Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just a nit

Comment on lines +111 to +116
from accelerate import Accelerator, init_on_device

with init_on_device(device=torch.device("cuda")):
tst = nn.Linear(100, 100) # on `cuda` device
accelerator = Accelerator()

with init_on_device(device=torch.device(accelerator.device)):
tst = nn.Linear(100, 100) # on specified device
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really recommended to initialize Accelerator when we are not training. maybe we can keep this example by adding a device variable. device = "cuda" # or "xpu" and so on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SunMarc , done, thx

Signed-off-by: Matrix YAO <matrix.yao@intel.com>
@yao-matrix
Copy link
Contributor Author

@SunMarc , pls take a second look, thx very much.

Signed-off-by: Matrix YAO <matrix.yao@intel.com>
@yao-matrix
Copy link
Contributor Author

@SunMarc I've fixed the ruff check issue, other issues seems not related to my PR, pls help check, thx.

@yao-matrix
Copy link
Contributor Author

@SunMarc , could you help take a second look? Thx very much.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@SunMarc SunMarc merged commit 00e4d26 into huggingface:main Jan 27, 2026
18 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants